<%-- 
    Name:     Nguyen Minh Trung
    Class:    SE0691
    Document   : savingFunctionJsp
    Created on : Nov 22, 2012, 4:09:42 PM
  
--%>
<%@page import="java.util.Date"%>
<%@page import="edu.fpt.common.Budget"%>
<%@page import="java.util.List"%>
<%@page import="edu.fpt.dal.BudgetDAL"%>
<%@taglib prefix="pf"
          uri="/WEB-INF/tlds/pf_tag_lib.tld"%>
<%@page import="edu.fpt.common.Saving"%>
<%@page import="Connection.savingConnection"%>
<%@page import="edu.fpt.dal.BudgetDAL"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Saving</title>
        <link rel="stylesheet" type="text/css" href="../Theme/style.css">
        <script src="../Theme/jquery-1.7.2.js" type="text/javascript">
        </script>
        <script src="../Theme/Script.js" type="text/javascript">
        </script>
    </head>
    <body>
        <pf:logo_tag/>
        <table border="0" style="margin-left: 50px; margin-top: 150px" >
            <tr>
                <td style="height: 500px; width: 180px;"><%@include file="/leftpannel.jsp" %></td>
                <td style="height: 500px; width: 750px;">
                    <div class="main_saving">
                        <div class="center" >
                            <center><div class="add"><a href="addSavingJSP.jsp"><table><tr><td><div class="add-butt">+</div></td><td><span style="color: white">ADD NEW SAVING</span></td></tr></table></a></div></center>

                            </form>
                        </div>
                        <table>
                            <%  List list = savingConnection.LishAll();
                                if (list != null) {
                                    for (int i = 0; i < list.size(); i++) {
                                        Saving sav = (Saving) list.get(i);%>

                            <tr class="entry" style="background-color: #31a1e7;">
                                <td class="bud-name"><%=sav.getName()%></td>
                                <td class="bud-type" ><%=sav.getType()%></td>
                                <td class="bud-amount"><%=sav.getAmount()%></td>
                                <td class="bud-time"><%=sav.getMonth()%>/<%=sav.getYear()%></td>
                                <%
                                    int id = sav.getId();
                                    float saving = Float.parseFloat(sav.getAmount().toString());
                                    float money = savingConnection.getSumAmount(sav.getMonth(), sav.getYear());

                                    if (saving > money) {
                                %>
                                <td><img src="image/success-icon.png" width="12px"</td>
                                    <%  } else {%> 
                                <td><img src="image/closeIcon.png" width="12px"</td>
                                    <% }%>
                                <td class="bud-butt"><a href="editSavingJSP.jsp?id=<%=sav.getId()%>" ><input type="submit" name="button-edit" class="butt_edit" value="EDIT"></a></td>
                                <td class="bud-del"><a href="../deleteSaving?id=<%=sav.getId()%>" ><img height="10px" width="10px" src="../Image/x.png"></a></td>
                            </tr> 
                            <% }
                                }%>
                        </table> 

                    </div>
                </td>
                <td style="height: 500px; width: 150px;"><%@include file="/rightpannel.jsp" %></td>
            </tr>
        </table>



    </body>
</html>
